﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyBatis.DataMapper;
using MyBatis.DataMapper.Configuration;
using MyBatis.DataMapper.Session;
using MyBatis.DataMapper.Configuration.Interpreters.Config.Xml;



namespace MvcDeviceManager.Util
{
    
    public class DaoUtil
    {
        IDataMapper dataMapper;
        string resource = "SqlMap.Config";
        private static DaoUtil util = null;
        private DaoUtil()
        {
            IConfigurationEngine engine = new DefaultConfigurationEngine();
            engine.RegisterInterpreter(new XmlConfigurationInterpreter(resource));
            IMapperFactory mapperFactory = engine.BuildMapperFactory();
            dataMapper = ((IDataMapperAccessor)mapperFactory).DataMapper;

        }
        public static IDataMapper getSqlMapper()
        {
            if (util == null)
            {
                util = new DaoUtil();
            }

            return util.dataMapper;
        }
    }
}